package myWindows;

import java.awt.FlowLayout;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import miscelaneos.JUtilities;

public class JTestAL extends JMyVentana {
    public JTestAL() {
        InitGUI();
    }
    
    JTextField jTexto1, jTexto2;
    JPasswordField jClave1, jClave2;
    
    public void InitGUI(){
        this.getContentPane().setLayout(new FlowLayout());
        
        jTexto1 = new JTextField(30);
        jTexto2 = new JTextField(30);
        jClave1 = new JPasswordField(30);
        jClave2 = new JPasswordField(30);
        
        this.getContentPane().add(jTexto1);
        this.getContentPane().add(jTexto2);
        this.getContentPane().add(jClave1);
        this.getContentPane().add(jClave2);
        
        MyOyente objList = new MyOyente();
        jTexto1.addActionListener(objList);
        jTexto2.addActionListener(objList);
        jClave1.addActionListener(objList);
        jClave2.addActionListener(objList);
        
    }
    
    class MyOyente implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            
            String strMensaje = "";
            if (e.getSource() == jTexto1){
                strMensaje = jTexto1.getClass().toString() + ": " + e.getActionCommand();
            }else if (e.getSource() == jTexto2){
                strMensaje = jTexto2.getClass().toString() + ": " + e.getActionCommand();
            }else if (e.getSource() == jClave1){
                strMensaje = jClave1.getClass().toString() + ": " + e.getActionCommand();
            }else if (e.getSource() == jClave2){
                strMensaje = jClave2.getClass().toString() + ": " + e.getActionCommand();
            }
            
            JUtilities.showMessageInformacion(strMensaje);
            
        }
    }

        
    public static void main(String[] args) {
        JTestAL obj = new JTestAL();
        obj.setVisible(true);

    }
}
